import React, {Component} from 'react';
import {StyleSheet, View, Text, FlatList, ScrollView, RefreshControl, ListView} from 'react-native';
import MJRefreshControl from './MJRefreshControl';
import MJFlatList from './MJFlatList';
// import {CbdScrollView} from 'react-native-mjrefresh'//rn>=0.55
const styles = StyleSheet.create({
    item: {  
      backgroundColor: '#f9f9f9',  
      padding: 10,  
      marginVertical: 8,  
      marginHorizontal: 16,  
    },  
    itemText: {  
      fontSize: 16
    },  
  });
const ItemView = ({item}) => (
    <View style={styles.item}>
      <Text style={styles.itemText}>{item.text}</Text>
    </View>
  );
  
const data = [{id:1, text:"Black", description:""},{id:2, text:"Black", description:""},{id:3, text:"Black", description:""},{id:4, text:"Black", description:""}]; 
export default class ListViewExample extends Component {
    constructor(props){
        super(props);
        var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
        this.state = {
          dataSource: ds.cloneWithRows(['row 1', 'row 2','row 3','row 4','row 5','row 6','row 7','row 8']),
      };
    }
//     _onRefresh=()=>{
//         setTimeout(()=>{
//             this._hw && this._hw.finishRefresh()
//         },1000)
//     }
    render() {
        return (
            <View style={{flex: 1}}>
                <ListView
                    dataSource={this.state.dataSource}
                    renderRow={(rowData) => <Text onPress={()=>alert(111)} style={{height:100}}>{rowData}</Text>}
                    renderScrollComponent={props=><ScrollView
                        refreshControl={
                            <MJRefreshControl
                                ref={ref=>this._hw = ref}
                                onRefresh={this._onRefresh}
                            />
                        }
                        {...props}
                    />}
                />
               
            </View>
        )
    }
// state={
//     text:'下拉刷新'
// }
// render() {
//     return (
//         <ScrollView
        
//             refreshControl={
//                 <MJRefreshControl
// //                                 ref={ref=>this._hw = ref}
// //                                 onRefresh={this._onRefresh}
//                             />
//             }
//         >
//          <Text>
//           Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
//           eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
//           minim veniam, quis nostrud exercitation ullamco laboris nisi ut
//           aliquip ex ea commodo consequat. Duis aute irure dolor in
//           reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
//           pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
//           culpa qui officia deserunt mollit anim id est laborum.
//         </Text>
//         </ScrollView>
//     );
//   }
}